package io.xccit.proxy;

import io.xccit.pojo.Calculator;

/**
 * @author Xccit
 * @Date 2023-01-29
 * @Description 静态代理类
 */
public class CalculatorStaticProxy implements Calculator {
    //目标对象
    private Calculator target;

    public CalculatorStaticProxy(Calculator target) {
        this.target = target;
    }

    @Override
    public int add(int i, int j) {
        System.out.println("add(),参数:"+i+":"+j);
        int result = target.add(i, j);
        System.out.println("add(),结果:"+result);
        return result;
    }

    @Override
    public int sub(int i, int j) {
        System.out.println("sub(),参数:"+i+":"+j);
        int result = target.sub(i, j);
        System.out.println("sub(),结果:"+result);
        return result;
    }

    @Override
    public int mul(int i, int j) {
        System.out.println("mul(),参数:"+i+":"+j);
        int result = target.mul(i, j);
        System.out.println("mul(),结果:"+result);
        return result;
    }

    @Override
    public int div(int i, int j) {
        System.out.println("div(),参数:"+i+":"+j);
        int result = target.div(i, j);
        System.out.println("div(),结果:"+result);
        return result;
    }
}
